import matplotlib.pyplot as plt
import numpy as np
def f(x,g):
    return 0.5*(x[0]**2+g*x[1]**2)
epsilon = 1e-4
gamma = np.linspace(0.1,10,20)
countls = []
for i in gamma:
    x0 = np.array([i,1])
    cnt = 0
    while f(x0,i)>epsilon:
        cnt+=1
        x1 = x0 * (i-1)/(i+1)
        x1[1] = -x1[1]
        x0 = x1
    countls.append(cnt)
plt.plot(gamma,countls)
plt.xlabel("gamma")
plt.ylabel("count")
plt.show()
